<?php

namespace app\admin\model\coupons;

use think\Model;


class Bind extends Model
{

    

    

    // 表名
    protected $name = 'coupons_bind';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'statuslist_text'
    ];
    

    
    public function getStatuslistList()
    {
        return ['0' => __('Statuslist 0'), '1' => __('Statuslist 1')];
    }
   public function getGroupList()
    {
        return ['0' => __('GroupList 1'), '1' => __('GroupList 2')];
    }

    public function getStatuslistTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['statuslist']) ? $data['statuslist'] : '');
        $list = $this->getStatuslistList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    public function usergroup()
    {
        return $this->belongsTo('app\admin\model\UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    public function userstaff()
    {
        return $this->belongsTo('app\admin\model\coupons\Userstaff', 'number', 'id', [], 'LEFT')->setEagerlyType(0);
    }




}